package com.cl.blog.web.manager;

import com.cl.blog.annotation.Login;
import com.cl.blog.common.Const;
import com.cl.blog.common.Result;
import com.cl.blog.entity.BAdmin;
import com.cl.blog.entity.BRole;
import com.cl.blog.service.BAdminService;
import com.cl.blog.service.BRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.Console;
import java.util.List;

/**
 * @Author 付
 * @Date 2024-03-15 17:45
 * @Version 1.0
 * @description
 * @since 1.0
 */
@RestController
@RequestMapping("/admin")
public class AdminController {
	@Resource
	BAdminService bAdminService;
	@Autowired
	BRoleService bRoleService;


	/**
	 * 获取管理员信息列表
	 * @return
	 */
//	@Login(issuer = Const.GRADE_ADMIN)
	@GetMapping("/list")
	public Result adminList(){
		List<BAdmin> list = bAdminService.list();
		for (BAdmin bAdmin: list){
			BRole byId = bRoleService.getById(bAdmin.getRoleId());
			bAdmin.setName(byId.getName());
			bAdmin.setStatus(byId.getStatus());
		}

		System.out.println("管理员数据"+list);
		return Result.success(list);
	}

}
